﻿//------------------------------------------------------------------------------
// System Name:    Customer Service Platform
// Component:      User&Role2 Helper
// Created By:     Parker Zhou (milesch@wicresoft.com)
// Created Date:   2011-1-27
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ASBCC.Database.EntityFramework;

namespace ASBCC.Business.CCS
{
    /// <summary>
    /// user role service with Role2 for ccs
    /// </summary>
    public static class UserRole2Helper
    {
        /// <summary>
        /// Get new Roles(Roles) by employee's NameEN
        /// </summary>
        /// <param name="employeeNameEN"></param>
        /// <returns></returns>
        public static IEnumerable<Role> GetNewRolesByEmployeeNameEN(string employeeNameEN)
        {
            using (var db = new CCEntities())
            {
                var employee = db.Employees.FirstOrDefault(e => e.NameEN == employeeNameEN);
                if (employee == null) throw new Exception(string.Format("The Employee with {0} was not found", employeeNameEN));
                employee.Roles.Load();
                return employee.Roles;
            }
        }
    }
}
